package org.example.myleet.rosalind.cstr;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Solution {
    public static void main(String[] args) throws IOException {
        Solution solution = new Solution();
        String path = solution.getClass().getResource("").getPath() + "example.txt";
        BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(path)));
        List<String> dnaList = new ArrayList<>();
        String line;
        while (null != (line = br.readLine())) {
            line = line.trim();
            if (line.length() < 1) {
                break;
            }
            dnaList.add(line);
        }
        //针对每个column的字符进行分析，只有SNP位点存在多于1行是不同的情况下才算是trivial的SNP，才能用来区分种类
        int r = dnaList.size();
        int c = dnaList.get(0).length();
        for (int j = 0; j < c; ++j) {
            int sameWithDna0Count = 1;
            char dna0char = dnaList.get(0).charAt(j);
            StringBuilder sb = new StringBuilder();
            sb.append('1');
            for (int i = 1; i < r; ++i) {
                if (dna0char == dnaList.get(i).charAt(j)) {
                    ++sameWithDna0Count;
                    sb.append('1');
                } else {
                    sb.append('0');
                }
            }
            if (sameWithDna0Count > 1 && sameWithDna0Count < r - 1) {
                System.out.println(sb);
            }
        }
        br.close();
    }
}
